import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import {Button } from 'antd';
// 由于 antd 组件的默认文案是英文，所以需要修改为中文
import zhCN from 'antd/lib/locale-provider/zh_CN';
import moment from 'moment';
import 'moment/locale/zh-cn';
import "antd/dist/antd.css";
import "./index.css";
import 'whatwg-fetch'
class App extends Component {
    constructor(props) {
        super(props);
        this.state = {
            filmlist: [{id: null, filmName: "234", boxOfficeStr: null }]
        };

    }

    render() {
        let aaa=null;

    return (
      <div className="App">
        <header className="App-header">
            <table border="1">
                <tr>
                    <th width="100">id</th>
                    <th width="300">影片</th>
                    <th width="300">票房</th>
                </tr>
                {
                    this.state.filmlist.map((myjson)=>{
                        return <tr><td>{myjson.id}</td><td>{myjson.filmName}</td><td>{myjson.boxOfficeStr}</td></tr>
                    })
                }
            </table>
        </header>
      </div>
    );
  }
    componentDidMount() {
        fetch('/test',{
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            // body: JSON.stringify({})
        })
            .then(response => response.json())
            .then(data =>{
               /* alert(data)*/
                this.setState({filmlist:data});
            })
            .catch(
                error =>alert("2345678"+error)
            );
    }
}

export default App;
